package com.situ.study.day2;

import org.junit.Test;

import java.util.Scanner;

/**
 * Java是纯面向对象的语言，所有的代码都要写到类里面
 * Shift+Enter 在光标所在行下一下插入一行
 */
public class HelloWorld {

    //main方法是程序的入口
    public static void main(String[] args) {
        //sout
        System.out.println();
        //soutm
        System.out.println("HelloWorld.main");
        //variable:变量 var   // age == 10
        int age1 = 10;// =是双目运算符   age++ ++单目运算符
        age1 = 12;
        //常量 final variable
        final int num = 10;
        //Cannot assign a value to final variable 'num'
        //assign:赋值
        //num = 12;

        //这个变量想表达什么意思就起什么名字
        int a = -21;
        int b = 23;

        //test1();
    }

    //junit:java unit
    //HelloWorld:驼峰命名法
    //Alt+Enter:快速修复一些错误
    @Test
    public void test1() {
        //int num1 = 2231414312;
        long num = 2231414312L;

        byte num2 = 13;
        //byte num3 = 128;
        byte num4 = -128;

        double d = 3.14;
        System.out.println(d);
        System.out.println("d:" + d);
    }

    @Test
    public void test2() {
        char ch1 = 'a';
        char ch2 = 'A';
        //char ch3 = '中';
        System.out.println(ch1);//a
        System.out.println(ch2);
        //System.out.println(ch3);

        /*
            1、从小到大自动类型转换
            2、从大到小需要强制类型转换，可能会丢失精度(装水的杯子大小不一样)
            byte->short(char)->int->long->float->double
        */
        System.out.println(ch1 + 1);//98  97+1
        int num = ch1 + 1;
        char ch4 = (char)num;
        System.out.println((char)(ch1 + 1));

        double d = 3.14;
        int n = (int)d;
        System.out.println(n);//3

        boolean b1 = true;
        b1 = false;
        boolean b2 = false;
    }

    @Test
    public void test3() {
        int num1 = 3;
        int num2 = 5;
        int result = num1 + num2;
        System.out.println(result);

        System.out.println(8 / 2);//4
        System.out.println(8 % 2);//0
        System.out.println(8 / 5);//1
        System.out.println(8 % 5);//3
    }

    @Test
    public void test5() {
        //1、单独使用的时候，++、--在前后是没有差别的
        //2、被使用的时候，在前后是有差别的
        int i = 3;
        i++;//++i  i=i+1
        System.out.println(i);//4
        System.out.println(i++);//4  i=5
        System.out.println(++i);//6
    }

    //比较运算符：>   <    >=     <=    !=
    @Test
    public void test6() {
        System.out.println(3 > 5);//false
        System.out.println(5 < 10);//true
        System.out.println(5 <= 10);//true
    }

    // 逻辑运算符：&&   ||   ！ 运算结果也是boolean类型
    //&&：两边的结果都是true，结果才是true
    //||：两边只要有一个是true，结果就是true
    @Test
    public void test7() {
        int score1 = 67;
        int score2 = 320;
        boolean result1 = (score1 >= 60) && (score2 >= 400);
        System.out.println(result1);
        boolean result2 = (score1 >= 60) || (score2 >= 400);
        System.out.println(result2);

        boolean b = true;
        System.out.println(!b);
    }

    @Test
    public void test11() {
        int num = 4;
        //可以是现在控制台输入
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入一个成绩");
        int score = scanner.nextInt();
        System.out.println("score: " + score);
    }
}
